def init_BB() :
    uart.write(b'\xbb\xdc\x12\x80\x4e')
    utime.sleep_ms(50)
    res=uart.read(3)
    print(res)
    uart.write(b'\xbb\xdc\x11\x30\xfd') 
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x1b\x06\xc1')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x6b\x43\xf4')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x12\x20\xee')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x3a\x00\xe6')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x15\x02\xcb')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x62\x81\x3f')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x08\xa0\x74')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x06\x68\xb2')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x2b\x20\xd7')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x92\x25\x6b')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x27\x97\x6c')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x17\x01\xca')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x18\x79\xbd')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x19\x00\xc5')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x1a\xa0\x66') 
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x03\x00\xdf')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x13\x00\xcf')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x01\x13\xce')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x02\x20\xfe')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x87\x16\x4d')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x8c\x01\x51')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x8d\xcc\x9d')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x13\x07\xc8')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x33\x10\xff')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x34\x1d\xf5')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x35\x46\xaf')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x36\x40\xaa')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x37\xa4\x4f')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x38\x7c\x98')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x65\x46\xff')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x66\x46\xfc')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x6e\x20\x92')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x9b\xa4\xe3')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x9c\x7c\x3c')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xbc\x0c\x6c')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xbd\xa4\xc5')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xbe\x7c\x1e')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x20\x09\xf5')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x09\x03\xd6')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x72\x2f\x81')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x73\x2f\x80')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x74\xa7\x0f')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x75\x12\xbb')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x79\x8d\x28')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x7a\x00\xa6')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x7e\xfa\x58')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x70\x0f\xa3')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x7c\x84\x24')
    utime.sleep_ms(50)
    res=uart.read(3)
    print(res)
    uart.write(b'\xbb\xdc\x7d\xba\x1b')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x5b\xc2\x45')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x76\x90\x3a')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x7b\x55\xf2')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x71\x46\xeb')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x77\xdd\x76')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x13\x0f\xc0')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x8a\x10\x46')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x8b\x20\x77')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x8e\x21\x73')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x8f\x40\x13')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x94\x41\x09')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x95\x7e\x37')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x96\x7f\x35')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x97\xf3\xb8')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x13\x07\xc8')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x24\x58\xa0')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x97\x48\x03')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x25\x08\xf1')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x94\xb5\xfd')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x95\xc0\x89')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x80\xf4\xa8')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x81\xe0\xbd')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x82\x1b\x45')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x83\x37\x68')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x84\x39\x61')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x85\x58\x01')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x86\xff\xa5')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x89\x15\x40')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x8a\xb8\xee')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x8b\x99\xce')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x39\x98\x7d')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x3f\x98\x7b')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x90\xa0\xec')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x91\xe0\xad')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x40\x20\xbc')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x41\x28\xb5')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x42\x26\xb8')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x43\x25\xba')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x44\x1f\x87')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x45\x1a\x83')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x46\x16\x8c')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x47\x12\x89')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x48\x0f\x9b')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x49\x0d\x98')
    utime.sleep_ms(50)
    res=uart.read(3)
    print(res)
    uart.write(b'\xbb\xdc\x4b\x0b\x9c')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x4c\x0a\x9a')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x4e\x08\x9a')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x4f\x06\x95')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x50\x06\x8a')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x5a\x56\xd0')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x51\x1b\x96')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x52\x04\x8a')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x53\x4a\xc5')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x54\x26\xae')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x57\x75\xfe')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x58\x2b\xaf')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x5a\xd6\x50')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x51\x28\xa5')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x52\x1e\x90')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x53\x9e\x11')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x54\x70\xf8')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x57\x50\xdb')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x58\x07\x83')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x5c\x28\xa8')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xb0\xe0\x8c')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xb1\xc0\xad')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xb2\xb0\xde')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xb3\x4f\x20')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xb4\x63\x0b')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xb4\xe3\x8b')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xb1\xf0\x9d')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xb2\xa0\xce')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x55\x00\x89')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x56\x40\xca')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x96\x50\x1a')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x9a\x30\x76')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x6a\x81\x37')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x23\x33\xcc')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xa0\xd0\xac')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xa1\x31\x4c')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xa6\x04\x7e')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xa2\x0f\x71')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xa3\x2b\x54')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xa4\x0f\x77')
    utime.sleep_ms(50)
    res=uart.read(3)
    print(res)
    uart.write(b'\xbb\xdc\xa5\x2b\x52')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xa7\x9a\xe1')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xa8\x1c\x68')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xa9\x11\x64')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xaa\x16\x60')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xab\x16\x61')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xac\x3c\x4c')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xad\xf0\x81')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xae\x57\x25')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xc6\xaa\xb0')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xd2\x78\x76')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xd0\xb4\xb8')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xd1\x00\x0d')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xc8\x10\x04')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xc9\x12\x07')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xd3\x09\x06')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xd4\x2a\x22')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\xee\x4c\x7e')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x7e\xfa\x58')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x74\xa7\x0f')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x78\x4e\xea')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x60\xe7\x5b')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x61\xc8\x75')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x6d\x70\xc1')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x1e\x39\xfb')
    utime.sleep_ms(50)
    uart.read()
    uart.write(b'\xbb\xdc\x98\x1a\x5e')
    utime.sleep_ms(50)
    res=uart.read(3)
    print(res)

def xylight_init():
    uart.write(b'\xaa')
    utime.sleep_ms(50)
    uart.write(b'\xab\x96\x26\xbc\x50\x5c')
    utime.sleep_ms(50)
    res=uart.read(3)
    print(res)
    if res != b'\xab\x00\xab' :
       while res != b'\xab\x00\xab' :
        uart.write(b'\xab\x96\x26\xbc\x50\x5c')
        utime.sleep_ms(50)
        res=uart.read(3)
    else:
      print("AB command success")
    init_BB()
    print("BB command success")
    uart.write(b'0xdd')
    utime.sleep(1)
    print("init complete")
xylight_init()

print("one")
for i in range(0,169):
    uart.write(bytes([i]))
    utime.sleep_ms(50)
    print(uart.read())
print("two")
for i in range(172,186):
    uart.write(bytes([i]))
    utime.sleep_ms(50)
    print(uart.read())
print("three")
for i in range(188,255):
    uart.write(bytes([i]))
    utime.sleep_ms(50)
    print(uart.read())